//Groups and ranges
const num = ["135", "189", "199", "120"];

const rge = /1[3-9]\d/;

const res = num.filter(item => rge.test(item));
console.log(res);

//量词 quality

const str1 = "my name is you dad";
const reg1 = /[a-z]{1,}/gi;

console.log(str1.match(reg1).join("-"));

//匹配标签
const tag = "<div>bagelalu</div><span>hello</span><h2></h2>";
const rgeTag = /\<\/?[a-z0-9]{1,}\>/g;

console.log(tag.match(rgeTag));

//贪婪
const book = "my favorate books has <<数据结构与算法>> 和<<大话数据结构>>";
// const bookRge = /\<\<.+\>\>/g;
const bookRge1 = /<<.+>>/g; //贪婪 =>[ '<<数据结构与算法>> 和<<大话数据结构>>' ] 一直找到最后才返回
const bookRge2 = /<<.+?>>/g; //惰性 =>[ '<<数据结构与算法>> <<大话数据结构>>' ] 找到就返回
console.log(book.match(bookRge2));

//捕获组
//匹配标签
const tag2 = "<div>bagelalu</div><span>hello</span><h2></h2>";
// const rgeTag2 = /<\/?([a-z][a-z0-9]+)>/gi;
const rgeTag2 = /<([a-z][a-z0-9]+?)>/gi; //开启惰性模式
var res2 = tag2.matchAll(rgeTag2);

for (const item of res2) {
  console.log(item[1]);
}

//单体捕获组
const strabc = "abclllllsadihabcabcgggs";
console.log("\n", strabc.match(/(abc){2,}[a-z]{2}/gi)); // [ 'abcabcgg' ]
